// SPDX-License-Identifier: GPL-2.0 or GPL-3.0
// Copyright © 2018-2019 Ariadne Devos
/* shttpd - functions for control threads */

#ifndef _sHT_CONTROL_H
#define _sHT_CONTROL_H

struct sHT_node
{
	union {
		/* Only for killing misbehaving processes */
		int pid_err;
		/* Only for sHT_start_worker */
		int worker_fd_err;
	};
	/* Our end of it. A non-blocking SOCK_SEQPACKET, UNIX domain socket. */
	int controlfd;
};

/* errno values vary by architecture */
enum sHT_node_errno
{
	sHT_NODE_OTHER = 0,
	sHT_NODE_EINVAL,
	sHT_NODE_EMFILE,
	sHT_NODE_ENFILE,
	sHT_NODE_EAGAIN,
	sHT_NODE_ENOMEM,
	sHT_NODE_EPERM,
};

/* Possible error values:
   -EINVAL (bug)
   -EMFILE (process file descriptor limit)
   -ENFILE (process file descriptor limit)
   -EAGAIN (too many processes)
   -ENOMEM (lack of kernel memory)
   -EPERM (not allowed, configuration bug)
   Others that are not listed in the man pages
 */
struct sHT_node
sHT_start_worker(int workerfd);

#endif
